import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/adminlogin',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/openai',
    component: () => import('@/views/login/openai'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [



  {
    path: '/news',
    component: Layout,
    name: '行业资讯',
    meta: {
      title: '行业资讯',
      icon: 'el-icon-bell'
    },
    children: [
      {
        path: '/industry',
        component: () => import('@/views/news/index'),
        name: 'industryNews',
        meta: { title: '行业资讯', icon: 'el-icon-bell' }
      },
    ]
  },
  {
    path: '/report',
    component: Layout,
    redirect: '/report/list',
    name: '订单列表',
    meta: {
      title: '订单列表',
      icon: 'el-icon-s-order'
    },
    children: [
  
      {
        path: 'txlist',
        component: () => import('@/views/report/list'),
        name: 'txlist',
        meta: { title: '提现列表', icon: 'list' }
      },
      {
        path: 'goodslist',
        component: () => import('@/views/oder/index'),
        name: 'ComplexTable',
        meta: { title: '订单列表', icon: 'list' }
      },

      {
        path: 'details/:id',
        component: () => import('@/views/oder/details'),
        name: 'EditArticle',
        meta: { title: '详情', noCache: true, },
        hidden: true
      },
      //
      // {
      //   path: '/wy_order_list',
      //   component: () => import('@/views/wuye/oderlist'),
      //   name: 'wy_order_list',
      //   meta: { title: '预约列表', icon: 'table' }
      // },



    ]
  },

  {
    path: '/storeshop',
    component: Layout,
    meta: {
      title: '商家管理',
      icon: 'el-icon-s-platform'
    },
    children: [
      {
        path: '/shop_list',
        component: () => import('@/views/store/null'),
        name: 'shop_list',
        meta: { title: '商家列表', icon: 'el-icon-s-shop' },
        children: [
          {
            path: 'guwan_shop',
            component: () => import('@/views/store/guwan/index'),
            name: 'guwan_shop',
            meta: { title: '综合商家', icon: 'list' }
          },
          {
            path: 'guwan_shop_detail',
            component: () => import('@/views/store/guwan/detail'),
            name: 'guwan_shopdetail',
            hidden: true,
            meta: { title: '商家详情', icon: '' }
          },

          {
            path: 'zhaoshang_shop',
            component: () => import('@/views/store/zhaoshang/index'),
            name: 'zhaoshang_shop',
            meta: { title: '招商经理', icon: 'list' }
          },
          {
            path: 'zhaoshang_shop_detail',
            component: () => import('@/views/store/zhaoshang/detail'),
            name: 'zhaoshang_shop_detail',
            hidden: true,
            meta: { title: '招商经理详情', icon: 'list' }
          },

          {
            path: 'proxy_shop',
            component: () => import('@/views/store/proxy/index'),
            name: 'proxy_shop',
            meta: { title: '区域代理', icon: 'list' }
          },
          {
            path: 'proxy_shop_detail',
            component: () => import('@/views/store/proxy/detail'),
            name: 'proxy_shop_detail',
            hidden: true,
            meta: { title: '区域代理详情', icon: 'list' }
          },

          {
            path: 'painter',
            component: () => import('@/views/store/painter/index'),
            name: 'painter',
            meta: { title: '名人书画家', icon: 'list' }
          },
          {
            path: 'painter_detail',
            component: () => import('@/views/store/painter/detail'),
            name: 'painter_detail',
            hidden: true,
            meta: { title: '名人书画家详情', icon: 'list' }
          },

          {
            path: 'appraiser',
            component: () => import('@/views/store/appraiser/index'),
            name: 'appraiser',
            meta: { title: '评估鉴定师', icon: 'list' }
          },
          {
            path: 'appraiser_detail',
            component: () => import('@/views/store/appraiser/detail'),
            name: 'appraiser_detail',
            hidden: true,
            meta: { title: '评估鉴定师详情', icon: 'list' }
          },
          {
            path: 'appraiser_store',
            component: () => import('@/views/store/appraiser_store/index'),
            name: 'appraiser_store',
            meta: { title: '评估鉴定机构', icon: 'list' }
          },
          {
            path: 'appraiser_store_detail',
            component: () => import('@/views/store/appraiser_store/detail'),
            name: 'appraiser_store_detail',
            hidden: true,
            meta: { title: '评估鉴定机构详情', icon: 'list' }
          },


          {
            path: 'auction_ompany',
            component: () => import('@/views/store/auction_ompany/index'),
            name: 'auction_ompany',
            meta: { title: '拍卖公司', icon: 'list' }
          },
          {
            path: 'xiehui',
            component: () => import('@/views/store/xiehui/index'),
            name: 'auction_ompany',
            meta: { title: '行业协会', icon: 'list' }
          },
          {
            path: 'bowuguan',
            component: () => import('@/views/store/bowuguan/index'),
            name: 'auction_ompany',
            meta: { title: '私人博物馆', icon: 'list' }
          },
          {
            path: 'auction_ompany_detail',
            component: () => import('@/views/store/auction_ompany/detail'),
            name: 'auction_ompany_detail',
            hidden: true,
            meta: { title: '拍卖公司详情', icon: 'list' }
          },

          // {
          //   path: 'allLines',
          //   component: () => import('@/views/store/allLines/index'),
          //   name: 'allLines',
          //   meta: { title: '360行商户', icon: 'list' }
          // },
          {
            path: 'allLines_detail',
            component: () => import('@/views/store/allLines/detail'),
            name: 'allLines_detail',
            hidden: true,
            meta: { title: '360行商户详情', icon: 'list' }
          },



          // {
          //   path: 'zhaoshang_shop',
          //   component: () => import('@/views/store/zhaoshang/index'),
          //   name: 'zhaoshang_shop',
          //   meta: { title: '招商经理', icon: 'table' }
          // },
          // // {
          // //   path: 'zhaoshang_shop_detail',
          // //   component: () => import('@/views/store/zhaoshang/detail'),
          // //   name: 'zhaoshang_shop_detail',
          // //   hidden: true,
          // //   meta: { title: '招商经理详情', icon: 'table' }
          // // },
          //
          //
          // {
          //   path: '/setlogs',
          //   component: () => import('@/views/logs/setlogs'),
          //   name: 'setlogs',
          //   meta: { title: '招商管理', icon: 'table' }
          // }
        ]
      },
      {
        path: '/market',
        component: () => import('@/views/market/index'),
        name: 'market',
        meta: { title: '市场管理', icon: 'el-icon-s-grid' }
      },

    ]
  },

  {
    path: '/userlist',
    name: '用户管理',
    meta: {
      title: '用户管理',
      icon: 'el-icon-s-custom'
    },
    component: Layout,
    children: [
      {
        path: 'list',
        component: () => import('@/views/userlist/index'),
        name: 'useerlist',
        meta: { title: '用户列表', icon: 'el-icon-tickets' }
      },
      {
        path: 'address',
        component: () => import('@/views/userlist/address/index'),
        name: 'useraddress',
        meta: { title: '用户收获地址', icon: 'el-icon-tickets' }
      },
      {
        path: 'card',
        component: () => import('@/views/userlist/card/index'),
        name: 'card',
        meta: { title: '用户银行卡', icon: 'el-icon-tickets' }
      },
      {
        path: 'zbreport',
        component: () => import('@/views/userlist/uzbreport/index'),
        name: 'zblist',
        meta: { title: '用户帐变记录', icon: 'el-icon-tickets' }
      },
      {
        path: 'ptzbreport',
        component: () => import('@/views/userlist/uzbreport/ptindex'),
        name: 'ptzbreport',
        meta: { title: '平台帐变记录', icon: 'el-icon-tickets' }
      },
      {
        path: 'detail/:name',
        component: () => import('@/views/userlist/list/index'),
        name: 'detail',
        hidden: true,
        meta: { title: '用户详情', icon: 'el-icon-tickets' }
      }
    ]
  },


  {
    path: '/shop',
    component: Layout,
    name: '商品/发布管理',
    meta: {
      title: '商品管理',
      icon: 'el-icon-s-goods'
    },
    children: [
      {
        path: '/shoplist',
        component: () => import('@/views/shop/index'),
        name: 'shoplist',
        meta: { title: '综合商品管理', icon: 'el-icon-s-goods' }
      },
      {
        path: '/allLineslist',
        component: () => import('@/views/shop/allLineslist'),
        name: 'allLineslist',
        meta: { title: '易货商品', icon: 'el-icon-s-goods' }
      },
      {
        path: '/paimaiad',
        component: () => import('@/views/shop/paimaiad'),
        name: 'paimaiad',
        meta: { title: '拍卖资讯发布', icon: 'el-icon-s-goods' }
      },
      {
        path: '/xiehuiad',
        component: () => import('@/views/shop/xiehuiad'),
        name: 'xiehuiad',
        meta: { title: '协会资讯发布', icon: 'el-icon-s-goods' }
      },
      {
        path: '/allLineslistAdlist',
        component: () => import('@/views/shop/paimaiadaadhhome'),
        name: 'allLineslistAdlist',
        meta: { title: '广告发布', icon: 'el-icon-s-goods' }
      },

      {
        path: 'auction',
        component: () => import('@/views/shop/auction'),
        name: 'auction',
        meta: { title: '拍卖商品', icon: 'el-icon-s-goods' }
      },
      {
        path: 'goodsDetails',
        component: () => import('@/views/shop/detail'),
        name: 'goodsDetails',
        hidden: true,
        meta: { title: '商品详情', icon: 'el-icon-s-goods' }
      },
      {
        path: 'auctiongoodsDetails',
        component: () => import('@/views/shop/auctiondetail'),
        name: 'auctiongoodsDetails',
        hidden: true,
        meta: { title: '拍品详情', icon: 'el-icon-s-goods' }
      },
      {
        path: 'yihuodetail',
        component: () => import('@/views/shop/yihuodetail'),
        name: 'yihuodetail',
        hidden: true,
        meta: { title: '易货详情', icon: 'el-icon-s-goods' }
      },
      // {
      //   path: '/listtype',
      //   component: () => import('@/views/shopcatype/index'),
      //   name: 'listtype',
      //   meta: { title: '商品管理', icon: 'table' }
      // },

    ]
  },

  {
    path: '/setting',
    component: Layout,
    name: '配置设置',
    meta: {
      title: '配置设置',
      icon: 'el-icon-s-tools'
    },
    children: [

      {
        path: '/av_hone',
        component: () => import('@/views/av_hone/index'),
        name: 'av_hone',
        meta: { title: '开屏首页配置', icon: 'el-icon-setting' }
      },

      {
        path: '/zyt_store_hone',
        component: () => import('@/views/zyt_store_hone/index'),
        name: 'zyt_store_hone',
        meta: { title: '周壹淘公司配置', icon: 'el-icon-setting' }
      },
      {
        path: 'list',
        component: () => import('@/views/setting/index'),
        name: 'banner',
        meta: { title: 'banner', icon: 'el-icon-setting' }
      },
      {
        path: '/store_config',
        component: () => import('@/views/issue/index'),
        name: 'store_config',
        meta: { title: '商户入驻配置', icon: 'el-icon-setting' }
      },
      {
        path: '/agreement_config',
        component: () => import('@/views/agreement/index'),
        name: 'agreement_config',
        meta: { title: '协议配置', icon: 'el-icon-setting' }
      },
      {
        path: '/contract_cof',
        component: () => import('@/views/contract/cof'),
        name: 'contract',
        meta: { title: '合同配置', icon: 'el-icon-setting' }
      },
      {
        path: '/shopnav',
        component: () => import('@/views/shopnav/index'),
        name: 'shopnav',
        meta: { title: '行业分类', icon: 'table' }
      },

      {
        path: '/recharge_cof',
        component: () => import('@/views/recharge/cof'),
        name: 'recharge',
        meta: { title: '其他配置', icon: 'el-icon-setting' }
      },
    ]
  },


  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
